package com.stars.home.utils

import android.content.Context
import android.util.Log
import android.widget.ImageView
import coil.load
import com.luck.picture.lib.engine.ImageEngine
import com.luck.picture.lib.listener.OnImageCompleteCallback
import com.luck.picture.lib.widget.longimage.SubsamplingScaleImageView
import com.stars.home.utils.glide.GlideUtils
import java.io.File

/**
 *
 *on 2020/9/16
 */
 object  LoadEngin : ImageEngine {


    override fun loadImage(context: Context, url: String, imageView: ImageView) {
        // imageView.load(url)
        if(url.contains("content://")){
//            imageView.load(url) {
//                crossfade(true)
//                placeholder(R.drawable.picture_image_placeholder)
//                transformations(CircleCropTransformation())
//            }

//            imageView.load(url)
            GlideUtils.lImg(context,url,imageView)

        }else{
//            imageView.load(File(url))
            GlideUtils.lImg(context,url,imageView)

        }


        Log.e("-shy-", "url1=: "+url )

    }

    override fun loadImage(context: Context, url: String, imageView: ImageView, longImageView: SubsamplingScaleImageView?, callback: OnImageCompleteCallback?) {
//        imageView.load(url)
        GlideUtils.lImg(context,url,imageView)
        Log.e("-shy-", "url2=: "+url )

    }

    override fun loadImage(context: Context, url: String, imageView: ImageView, longImageView: SubsamplingScaleImageView?) {
//        imageView.load(url)
        GlideUtils.lImg(context,url,imageView)
        Log.e("-shy-", "url3=: "+url )


    }

    override fun loadAsGifImage(context: Context, url: String, imageView: ImageView) {
//        imageView.load(url)
        GlideUtils.lImg(context,url,imageView)
        Log.e("-shy-", "url4=: "+url )

    }

    override fun loadGridImage(context: Context, url: String, imageView: ImageView) {
        Log.e("-shy-", "url5=: "+url )
        if(url.contains("content://")){
//            imageView.load(url) {
//                crossfade(true)
//                placeholder(R.drawable.picture_image_placeholder)
//                transformations(CircleCropTransformation())
//            }

//            imageView.load(url)
            GlideUtils.lImg(context,url,imageView)

        }else{
//            imageView.load(File(url))
            GlideUtils.lImg(context,url,imageView)

        }

    }

    override fun loadFolderImage(context: Context, url: String, imageView: ImageView) {

        Log.e("-shy-", "url6=: "+url )
//        imageView.load(url) {
//            crossfade(true)
//            placeholder(R.drawable.picture_image_placeholder)
//            transformations(CircleCropTransformation())
//        }

//        imageView.load(url)
        GlideUtils.lImg(context,url,imageView)
    }


}
